<?php if (!defined('THINK_PATH')) exit();?><table id="dg"></table>


<!--工具栏 -->
<style>
#finaBox{
	display: none;

}
	.finaSeDiv{
		float:left;
		padding:10px 0 5px 10px;
		width:200px;
	}
	.finaSeDiv2{
		float:left;
		padding:10px 0 5px 10px;
		/*width:200px;*/
	}
	.finaSeDiv label,.finaSeDiv2 label{
		width:53px;
		float: left;
	}
	.table-btn-separator {
    float: center;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #fff;
  /*  width: 1200px;*/
}
</style>

<div id="tool">    

<table>
<tr>
	<td>
		<?php if(authCheck1('Home/Quality/add_quality')): ?><a href="#" id= "aaa1" class="easyui-linkbutton"  onclick='show_add()' data-options="iconCls:'icon-standard-folder-page',plain:true">添加</a><?php endif; ?>
	    <?php if(authCheck1('Home/Quality/del')): ?><a href="#" class="easyui-linkbutton"  onclick='dele()' data-options="iconCls:'icon-standard-page-white-delete',plain:true">删除</a><?php endif; ?>
	    <?php if(authCheck1('Home/Quality/edit')): ?><a href="#" class="easyui-linkbutton"  onclick='show_edit()' data-options="iconCls:'icon-standard-application-edit',plain:true">编辑</a><?php endif; ?>
	</td>
	<?php if(authCheck1('Home/Quality/add_quality,Home/Quality/del,Home/Quality/edit',1,1,'and')): ?><td>
	    	<div class="datagrid-btn-separator"></div>
		</td><?php endif; ?>
	<td>
		<?php if(authCheck1('Home/Quality/out')): ?><a href="#"  class="easyui-linkbutton"   onclick="excel()" data-options="iconCls:'icon-standard-page-white-excel',plain:true">导出</a><?php endif; ?>
	        <a href="#" class="easyui-linkbutton"  onclick="view()" data-options="iconCls:'icon-standard-application-view-gallery',plain:true">查看</a> 
	    <?php if(authCheck1('Home/Quality/pinglun')): ?><a href="#" class="easyui-linkbutton"  onclick="show_pinlun()" data-options="iconCls:'icon-standard-building-add',plain:true">回复</a><?php endif; ?>
	</td>
	<td>
    	<div class="datagrid-btn-separator"></div>
	</td>    
   	<td>
	  <a href="#" class="easyui-linkbutton"  onclick="reload()" data-options="iconCls:'icon-standard-arrow-refresh',plain:true">刷新</a> 
   	</td>
	<td>
	     <div class="datagrid-btn-separator"></div>
	</td>
   <td>
     	<div style="float:right;">        
               <input  id='searchbox' class="easyui-searchbox" data-options="" style="width:400px;"></input>
			   </div>
			  
			      
			   <div id="mm" style="width:400px">
			    <div data-options="name:'content',iconCls:'icon-standard-table-edit',selected:true">问题描述</div>

	<div data-options="name:'chuli',iconCls:'icon-standard-table-edit'">问题处理</div>
		<div data-options="name:'author',iconCls:'icon-standard-table-edit'">发布人</div>

</div>
	   </td>
	   	 <td>
     <div class="datagrid-btn-separator"></div>
 </td>
 	 <td>
       <a href="#" id="finaSearch" class="easyui-linkbutton"  onclick="finaSearch()" data-options="iconCls:'icon-search',plain:true">显示高级搜索</a>
 </td>
</tr>

</table>

<table  id="finaBox" style="display:none;">
<tr >
<td style="padding:0px 0px 0px 5px" colspan="5">
   <div class="table-btn-separator"></div>
</td>
</tr>
	<tr>
		<td>
			  <div class="finaSeDiv">
        <label for="name">问题描述:</label>
        <input class="easyui-textbox" type="text" name="content" id="f_content" style="width:130px;">
    </div>
		</td>
		<td>
			 <div class="finaSeDiv">
        <label for="name">处理:</label>
        <input class="easyui-textbox" type="text" name="chuli" id="f_chuli"style="width:130px;">
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">问题分类:</label>
        <select id="f_leibie" class="easyui-combobox" name="leibie" data-options="editable:false,panelHeight:'auto'" style="width:130px;">
            <option value="">.</option>
            <option value="lbj">零部件</option>
            <option value="sj">设计</option>
            <option value="gy">工艺</option>
            <option value="zp">装配</option>
            <option value="qt">其他</option>
        </select>
    </div>
		</td>
		<td>
			 <div class="finaSeDiv">
        <label for="name">车间:</label>
        <select id="f_cj" class="easyui-combobox" name="cj" data-options="editable:false,panelHeight:'auto'" style="width:130px;">
            <option value="">.</option>
            <option value="zp1">装配一车间</option>
            <option value="zp2">装配二车间</option>
            <option value="ns">内饰车间</option>
            <option value="sz1">试制一车间</option>
            <option value="sz2">试制二车间</option>
            <option value="ts">调试车间</option>
            <option value="yl">预留区</option>
        </select>
    </div>
		</td>
		<!-- <td>
			<div class="finaSeDiv">
        <label for="name">日期:</label>

        <input  name="creatdate" id="f_creatdate"   type= "text" class= "easyui-datebox" style="width:70px"/>到
         <input  name="creatdate" id="f_creatdate"   type= "text" class= "easyui-datebox" style="width:70px"/>
    </div>
		</td> -->
		<td>
			 <div class="finaSeDiv">
        <label for="name">班次:</label>
        <select id="f_banci" class="easyui-combobox" name="banci" data-options="editable:false,panelHeight:'auto'" style="width:130px;">
            <option value="">.</option>
            <option value="day">白班</option>
            <option value="night">夜班</option>
        </select>
    </div>
		</td>

	</tr>
	<tr>

		<td>
			<div class="finaSeDiv">
        <label for="name">计生号:</label>
        <input class="easyui-textbox" type="text" name="jsh" id="f_jsh" style="width:130px;">
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">流水号:</label>
        <input class="easyui-textbox" type="text" name="lsh" id="f_lsh" style="width:130px;">
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">协议号:</label>
        <input class="easyui-textbox" type="text" name="xy" id="f_xy" style="width:130px;">
    </div>
		</td>
		<td>
			 <div class="finaSeDiv">
        <label for="name">车型:</label>
        <input class="easyui-textbox" type="text" name="cxch" id="f_cxch" style="width:130px;">
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">作者:</label>
        <input class="easyui-textbox" type="text" name="nickname" id="f_author" style="width:130px;">
    </div>
		</td>
	</tr>
	<tr>
		<td>
			 <div class="finaSeDiv">
        <label for="name">车型平台:</label>
        <select id="f_pt" class="easyui-combobox" name="pt" data-options="editable:false,panelHeight:'auto'" style="width:130px;">
            <option value="">.</option>
            <option value="F3000">F3000</option>
            <option value="M3000">M3000</option>
            <option value="X3000">X3000</option>
            <option value="STR">奥龙</option>
            <option value="PZ">偏置</option>
            <option value="KY">矿用</option>
            <option value="QT">其他</option>
        </select>
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">车辆类别:</label>
        <select id="f_cx" class="easyui-combobox" name="cx" style="width:130px;" data-options="editable:false,panelHeight:'auto'">
            <option value="">.</option>
            <option value="1">载货车</option>
            <option value="2">越野车</option>
            <option value="3">自卸车</option>
            <option value="4">牵引车</option>
            <option value="5">专用车</option>
            <option value="6">其他</option>
        </select>
    </div>
		</td>
		
		<td>
			<div class="finaSeDiv">
        <label for="name">备注:</label>
        <input class="easyui-textbox" type="text" name="bz" id="f_bz" style="width:130px;">
    </div>
		</td>
		<td>
			<div class="finaSeDiv">
        <label for="name">分组:</label>
        <input class="easyui-textbox" type="text" name="dcs" id="f_dc" style="width:130px;">
    </div>
		</td>
		<td colspan="2">

		
			<div class="finaSeDiv2">
        <label for="name">日期:</label>

        <input  name="creatdates" id="f_creatdates"   type= "text" class= "easyui-datebox" style="width:100px"/>  到  
         <input  name="creatdatee" id="f_creatdatee"   type= "text" class= "easyui-datebox" style="width:100px"/>
  
        <a id="finSerBtn" href="#" onclick="finSerBtn()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
    </div>
		</td>
	</tr>
</table>




</div>

<script>
/**
 * [finaSearch 高级搜索显示]
 * @return {[type]} [description]
 */
function finaSearch(){
	$("#finaBox").slideToggle(function(){
	 	if($('#finaSearch').linkbutton("options").text=="显示高级搜索"){
		 	$('#finaSearch').linkbutton({    
	    		text: '隐藏高级搜索'   
			}); 
	 	}else{
	 		 $('#finaSearch').linkbutton({    
    			text: '显示高级搜索'   
			}); 
	 	}
	});
}
/**
 * [finSerBtn 高级搜索]
 * @return {[type]} [description]
 */
function finSerBtn(){
	$('#dg').datagrid('load',{
		content:$("#f_content").val(),
		chuli:$("#f_chuli").val(),
		leibie:$('#f_leibie').combobox('getValue'),
		banci:$('#f_banci').combobox('getValue'),
		cj:$('#f_cj').combobox('getValue'),
		jsh:$("#f_jsh").val(),
		lsh:$("#f_lsh").val(),
		xy:$("#f_xy").val(),
		cxch:$("#f_cxch").val(),
		creatdates:$("#f_creatdates").datebox('getValue'),
		creatdatee:$("#f_creatdatee").datebox('getValue'),
		pt:$('#f_pt').combobox('getValue'),
		cx:$('#f_cx').combobox('getValue'),
		nickname:$("#f_author").val(),
		dcs:$("#f_dc").val(),
		bz:$("#f_bz").val()
	});
}
</script>
<style>
    .uploadpic{
        float:left;
        width: 295px;
        text-align:center;
        height:165px;
    }
    .uploadpic h3{
        text-align:left;
        border:1px solid  #95B8E7;
        float:left;
        padding:4px;
        background-color:#95B8E7;
        color:#FFF;
    }
    .up-content{
        border:1px solid  #95B8E7;
        padding:4px;
    }
    .w10{
        float:left;
        width:10px;
        color:#FFF;
    }
    .items{
        padding:10px 0 4px 0;
        border-top: solid 1px #D6D4D4;
        display: block;
    }
    #dd div{
        padding-right: 10px;
        padding-bottom: 10px;
    }
    .addItems{
        float: left;
    }

/*表格样式  */
    .add_table{
        width:100%;
    }
    .add_table th{
        width:80px;
        background-color: #E0ECFF;
        padding: 8px 0 8px 0;
        border-right:solid 1px #95B8E7;
        border-bottom: solid 1px #95B8E7;
    }
    .add_table td{
        border-bottom: solid 1px #95B8E7;
    }
    .add_table tr{
        border:solid 1px #95B8E7;
    }
    .tb_head{
        text-align: center;
        padding: 10px;
        background-color: #E0ECFF;
        font-size: 20px;
        font-weight: bold;
    }
    .inline{
        display:inline
    }
    .row_container{
        padding:8px 5px 5px 5px;
    }
    .add_label{
width:72px;
display:-moz-inline-box; /* css注释：for ff2 */ 
display:inline-block; 
    }
</style>
<div id="add" class="easyui-dialog" style="width:1050px; height: 692px; padding: 0px; overflow: hidden;" title="记录添加" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-add',closed:true,resizable:true,modal:true,closable:true">
    <form id="add_form" action="/degs/index.php/Home/Quality/add_quality" enctype="multipart/form-data" method="post" >
    
<table class="add_table">
    <tr>
        <th>生产信息</th>
        <td>
            <div class="row_container" style="background: #FFFEE6;">
                <div class="inline">
                    <span class="add_label">创建时间：</span>
                     <input id="creatdate" name="creatdate" class="easyui-datetimebox" data-options="required:true,showSeconds:true" style="width:162px">
                </div>
                <div class="inline">
                    <span class="add_label">班次：</span>
                    <select id="banci" class="easyui-combobox" name="banci" style="width:132px;" data-options="editable:false,required:true,panelHeight:'auto'">                    
                        <option value="day" selected="selected">白班</option>
                        <option value="night">夜班</option>
                    </select>
                </div>
                <div class="inline">
                    <span class="add_label">车间：</span>
                     <select id="cj" class="easyui-combobox" name="cj" style="width:132px;" data-options="editable:false,required:true,panelHeight:'auto'">            
                    <option value="zp1" selected="selected">装配一车间</option>
                    <option value="zp2">装配二车间</option>
                    <option value="ns">内饰车间</option>
                    <option value="sz1">试制一车间</option>
                    <option value="sz2">试制二车间</option>

                    <option value="ts">调试车间</option>
                    <option value="yl">预留区</option>
                </select>
                </div>
                <div class="inline">
                    <span class="add_label">问题分类：</span>
                      <select id="leibie" class="easyui-combobox" name="leibie" data-options="editable:false,panelHeight:'auto',required:true" style="width: 132px;">      
                        <option value="lbj" selected="selected">零部件</option>
                        <option value="sj">设计</option>
                        <option value="gy">工艺</option>
                        <option value="zp">装配</option>
                        <option value="bzj">标准件</option>
                        <option value="qt">其他</option>
                    </select>
                </div>
               
            </div>
        </td>
    </tr>
    <th>基本信息</th>
        <td style="background-color:rgba(204, 204, 204, 0.4);">
            <div class="row_container">

            <div class="panel" style="display: block;">
                <div class="easyui-panel panel-body panel-body-noheader" style="padding: 5px; width: 100%;" title="">
                    <span class="add_label">流水号</span>
                     <input id="lshpp"  class="easyui-textbox" data-options="" />
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="pipei()">匹配</a>  
                        <span style="color:#8F5700;padding-left:15px;">请输入流水号并搜索匹配车辆其他信息</span>
                </div>
            </div>
            </div>
            <div class="row_container ">
                <div class="inline">
                    <span class="add_label">车型：</span>
                    <input id="cxch" name="cxch" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">驾驶室：</span>
                     <input id="pt" name="pt" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">车类：</span>
                     <input id="cx" name="cx" class="easyui-textbox" data-options="iconCls:'',editable:true,required:false"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">基线号：</span>
                     <input id="jxh" name="jxh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:false"   style="width:150px" />
                </div>
            </div>
            <div class="row_container">
                <div class="inline">
                    <span class="add_label">计生号：</span>
                    <input id="jsh" name="jsh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">流水号区间：</span>
                     <input id="lshqj" name="lsh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">协议号：</span>
                     <input id="xy" name="xy" class="easyui-textbox" data-options="iconCls:''"   style="width:150px" />
                </div>
                 <div class="inline">
                    <span class="add_label">研究院：</span>
                      <select id="fkbm" class="easyui-combobox" name="fkbm" data-options="editable:false,panelHeight:'auto',required:true" style="width: 150px;">      
                        <option value="" selected="selected">.</option>
                        <option value="军研所">军研所</option>
                        <option value="商研所">商研所</option>
                        <option value="特研所">特研所</option>
                        <option value="海外室">海外室</option>
                    </select>
                </div>
            </div>
            <div class="row_container">
                
                    <span class="add_label">计划描述：</span>
                     <input id="jhms" name="jhms" class="easyui-textbox" data-options="multiline:true,editable:false,prompt:'灰色区域内容由上面流水号匹配得出……',required:true" style="width:90%;height:80px;">
            
            </div>
        </td>
    </tr>
          <tr>
        <th>分组号</th>
        <td>
             <!-- textarea name="chuli" class="easyui-textbox" id="chuli" style="width: 100%; height: 46px;" onkeyup="" data-options="required:true"></textarea> -->
              <input id="dc" name="dcs" class="easyui-textbox" data-options="multiline:false,editable:true,prompt:'请输入分组号……',required:true" style="width:60%;">
            <br />
        </td>
    </tr>
    <tr>
        <th>问题描述</th>
        <td>
             <textarea name="content" class="easyui-textbox" id="content" style="width: 100%; height: 46px;"  data-options="required:true"></textarea>
            <br />
            <div id="content_wordage"></div>
        </td>
    </tr>

    <tr>
        <th>现场处理</th>
        <td>
             <textarea name="chuli" class="easyui-textbox" id="chuli" style="width: 100%; height: 46px;" onkeyup="" data-options="required:true"></textarea>
            <br />
            <div id="chuli_wordage"></div>
        </td>
    </tr>
   
    <tr>
        <th>上传图片</th>
        <td>
            <div class="easyui-panel" style="padding:5px;"> 
                <input   type="file" name="pics[]" id="doc" multiple="multiple" style="width:150px;" onchange="javascript:setImagePreviews();" accept="image/*">
            </div>


<div style="width:100%;height:100px;">
    <div id="p" class="easyui-panel" title=""     
        style="padding:10px;background:#fafafa;"   
        data-options="iconCls:'icon-save',closable:true,    
                collapsible:true,minimizable:true,maximizable:true,fit:true">  
           <div id="dd" style=" width:100%;"></div>      
   
</div>
</div>




</div> 
        </td>
    </tr>
    <tr>
        <th>备注</th>
        <td>
            
             <textarea name="bz" class="easyui-textbox" id="bz" style="width: 100%; height: 46px;" onkeyup="" data-options=""></textarea>
            <br />
            <div id="bz_wordage"></div>
        </td>
    </tr>
</table>
    <input type="hidden" name="userid" id="userid" value= <?php echo ($_SESSION['uid']); ?>>
    <input type="hidden" name="author" id="author" value= <?php echo ($_SESSION['uname']); ?>>
    <input type="hidden" name="nickname" id="nickname" value= <?php echo ($_SESSION['unickname']); ?>>
    </form>

</div>

<div id="dlg-add">
    <div class="tool_tip">添加记录后会在列表中出现！！</div>
    <a href="#" id="addok" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
        onclick="add()">确认</a>
    <a href="#" class="easyui-linkbutton"
        data-options="iconCls:'icon-cancel'"
        onclick="javascript:$('#add').dialog('close')">取消</a>
</div>





<script>


function setImagePreviews(avalue) {
 
        var docObj = document.getElementById("doc");
 
        var dd = document.getElementById("dd");
 
        dd.innerHTML = "";
 
        var fileList = docObj.files;
 
        for (var i = 0; i < fileList.length; i++) {            
 
            dd.innerHTML += "<div style='float:left' > <img id='img" + i + "'  /> </div>";
 
            var imgObjPreview = document.getElementById("img"+i); 
 
            if (docObj.files && docObj.files[i]) {
 
                //火狐下，直接设img属性
 
                imgObjPreview.style.display = 'block';
 
                imgObjPreview.style.width = '100px';
 
                imgObjPreview.style.height = '70px';
 
                //imgObjPreview.src = docObj.files[0].getAsDataURL();
 
                //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
 
                imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
 
            }
 
            else {
 
                //IE下，使用滤镜
 
                docObj.select();
 
                var imgSrc = document.selection.createRange().text;
 
                alert(imgSrc)
 
                var localImagId = document.getElementById("img" + i);
 
                //必须设置初始大小
 
                localImagId.style.width = "150px";
 
                localImagId.style.height = "180px";
 
                //图片异常的捕捉，防止用户修改后缀来伪造图片
 
                try {
 
                    localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
 
                    localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
 
                }
 
                catch (e) {
 
                    alert("您上传的图片格式不正确，请重新选择!");
 
                    return false;
 
                }
 
                imgObjPreview.style.display = 'none';
 
                document.selection.empty();
 
            }
 
        }  
 
        return true;
 
    }

function CheckFile(obj) {
    var array = new Array('jpeg', 'png', 'jpg');  //可以上传的文件类型
    if (obj.value == '') {
        alert("请选择要上传的图片!");
        return false;
    }
    else {
        var fileContentType = obj.value.match(/^(.*)(\.)(.{1,8})$/)[3]; //这个文件类型正则很有用：）
        var isExists = false;
        for (var i in array) {
            if (fileContentType.toLowerCase() == array[i].toLowerCase()) {
                isExists = true;
                return true;
            }
        }
        if (isExists == false) {
            obj.value = null;
            alert("上传图片类型不正确!");
            return false;
        }
        return false;
    }
}

$(function(){
    var limitNumA = 100;
    var limitNumB = 255;
    var patternB = '还可以输入' + limitNumB + '字符';
    $('#content_wordage').html(patternB);
    $('#chuli_wordage').html(patternB);
$('#bz_wordage').html(patternB);
    $('#content').keyup(
    
    function(){
        var remain = $(this).val().length;
        if(remain > limitNumB){
                patternB = "字数超过限制！";
            }else{
                var result = limitNumB - remain;
                patternB = '还可以输入' + result + '字符';
            }
            $('#content_wordage').html(patternB);
        }
    );
       $('#bz').keyup(
    function(){
        var remain = $(this).val().length;
        if(remain > limitNumA){
                patternB = "字数超过限制！";
            }else{
                var result = limitNumA - remain;
                patternB = '还可以输入' + result + '字符';
            }
            $('#bz_wordage').html(patternB);
        }
    );

    $('#chuli').keyup(
    function(){

        var remain = $(this).val().length;
        if(remain > limitNumB){
                patternB = "字数超过限制！";
            }else{
                var result = limitNumB - remain;
                patternB = '还可以输入' + result + '字符';
            }
            $('#chuli_wordage').html(patternB);
        }
    );
    
    //显示图片
})

// 匹配MES信息
    function pipei(){

        // 匹配之前西安清空
        $('#lshqj').textbox('clear');
        $('#jsh').textbox('clear');
        $('#cx').textbox('clear');
        $('#pt').textbox('clear');
        $('#jhms').textbox('clear');
        $('#cxch').textbox('clear');
        $('#jxh').textbox('clear');
        // $('#fkbm').textbox('clear');
        var lsh=$('#lshpp').textbox('getText');
        if(lsh!=""){
             $.post("/degs/index.php/Home/Quality/pipei",{lsh:lsh},function(result){
                 // $("span").html(result);
                 console.log(result);
                 if(result.status=='1'){
                    $('#lshqj').textbox('setValue',result.data.lshqj);
                    $('#jsh').textbox('setValue',result.data.sjjhh);
                    $('#cx').textbox('setValue',result.data.cl);
                    $('#pt').textbox('setValue',result.data.jss);
                    $('#jhms').textbox('setValue',result.data.cjpz);
                    $('#cxch').textbox('setValue',result.data.cxch);
                    $('#jxh').textbox('setValue',result.data.jxh);
                    var leibie=$('#leibie').combobox('getValue');
                    if(leibie=='sj'){
                       $('#fkbm').combobox('setValue', result.data.fkbm); 
                   }else{
                    $('#fkbm').combobox('setValue', '');
                   }
                    



                 }else{
                    $.messager.alert('匹配车型信息', result.data, 'info');
                 }

            },"json");
        }else{
            $.messager.alert('匹配车型信息', '请输入流水号', 'info');
        }
    }

 
</script>

<style>
    .uploadpic{
        float:left;
        width: 295px;
        text-align:center;
        height:165px;
    }
    .uploadpic h3{
        text-align:left;
        border:1px solid  #95B8E7;
        float:left;
        padding:4px;
        background-color:#95B8E7;
        color:#FFF;
    }
    .up-content{
        border:1px solid  #95B8E7;
        padding:4px;
    }
    .w10{
        float:left;
        width:10px;
        color:#FFF;
    }
    .items{
        padding:10px 0 4px 0;
        border-top: solid 1px #D6D4D4;
        display: block;
    }
    #dd div{
        padding-right: 10px;
        padding-bottom: 10px;
    }
    .addItems{
        float: left;
    }

/*表格样式  */
    .add_table{
        width:100%;
    }
    .add_table th{
        width:80px;
        background-color: #E0ECFF;
        padding: 8px 0 8px 0;
        border-right:solid 1px #95B8E7;
        border-bottom: solid 1px #95B8E7;
    }
    .add_table td{
        border-bottom: solid 1px #95B8E7;
    }
    .add_table tr{
        border:solid 1px #95B8E7;
    }
    .tb_head{
        text-align: center;
        padding: 10px;
        background-color: #E0ECFF;
        font-size: 20px;
        font-weight: bold;
    }
    .inline{
        display:inline
    }
    .row_container{
        padding:8px 5px 5px 5px;
    }
    .add_label{
width:72px;
display:-moz-inline-box; /* css注释：for ff2 */ 
display:inline-block; 
    }
    
</style>
<div id="edit" class="easyui-dialog" style="width:1036px; height: 511px;padding:0px;overflow:hidden;" title="&nbsp;&nbsp;编辑记录" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-edit',closed:true,resizable:true,modal:true,closable:true">
    <form id="edit_form" method="post">
     <table class="add_table">
    <tr>
        <th>生产信息</th>
        <td>
            <div class="row_container" style="background: #FFFEE6;">
                <div class="inline">
                    <span class="add_label">创建时间：</span>
                     <input id="creatdate_edit" name="creatdate" class="easyui-datetimebox" data-options="required:true,showSeconds:true" style="width:132px">
                </div>
                <div class="inline">
                    <span class="add_label">班次：</span>
                    <select id="banci_edit" class="easyui-combobox" name="banci" style="width:132px;" data-options="editable:false,required:true,panelHeight:'auto'">                    
                        <option value="day" selected="selected">白班</option>
                        <option value="night">夜班</option>
                    </select>
                </div>
                <div class="inline">
                    <span class="add_label">车间：</span>
                     <select id="cj_edit" class="easyui-combobox" name="cj" style="width:132px;" data-options="editable:false,required:true,panelHeight:'auto'">            
                    <option value="zp1" selected="selected">装配一车间</option>
                    <option value="zp2">装配二车间</option>
                    <option value="ns">内饰车间</option>
                    <option value="sz1">试制一车间</option>
                    <option value="sz2">试制二车间</option>

                    <option value="ts">调试车间</option>
                    <option value="yl">预留区</option>
                </select>
                </div>
                <div class="inline">
                    <span class="add_label">问题分类：</span>
                      <select id="leibie_edit" class="easyui-combobox" name="leibie" data-options="editable:false,panelHeight:'auto',required:true" style="width: 150px;">      
                        <option value="lbj" selected="selected">零部件</option>
                        <option value="sj">设计</option>
                        <option value="gy">工艺</option>
                        <option value="zp">装配</option>
                        <option value="bzj">标准件</option>
                        <option value="qt">其他</option>
                    </select>
                </div>
            </div>
        </td>
    </tr>
    <th>基本信息</th>
        <td style="background-color:rgba(204, 204, 204, 0.4);">
            <div class="row_container">

            <div class="panel" style="display: block;">
                <div class="easyui-panel panel-body panel-body-noheader" style="padding: 5px; width: 100%;" title="">
                    <span class="add_label">流水号</span>
                     <input id="lshpp_edit"  class="easyui-textbox" data-options="" />
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="pipei1()">匹配</a>  
                        <span style="color:#8F5700;padding-left:15px;">请输入流水号并搜索匹配车辆其他信息</span>
                </div>
            </div>
            </div>
            <div class="row_container ">
                <div class="inline">
                    <span class="add_label">车型：</span>
                    <input id="cxch_edit" name="cxch" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">驾驶室：</span>
                     <input id="pt_edit" name="pt" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">车类：</span>
                     <input id="cx_edit" name="cx" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                 <div class="inline">
                    <span class="add_label">基线号：</span>
                     <input id="jxh_edit" name="jxh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
            </div>
            <div class="row_container">
                <div class="inline">
                    <span class="add_label">计生号：</span>
                    <input id="jsh_edit" name="jsh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">流水号区间：</span>
                     <input id="lshqj_edit" name="lsh" class="easyui-textbox" data-options="iconCls:'',editable:false,required:true"   style="width:150px" />
                </div>
                <div class="inline">
                    <span class="add_label">协议号：</span>
                     <input id="xy_edit" name="xy" class="easyui-textbox" data-options="iconCls:''"   style="width:150px" />
                </div>
                 <div class="inline">
                    <span class="add_label">研究院：</span>
                      <select id="fkbm_edit" class="easyui-combobox" name="fkbm" data-options="editable:false,panelHeight:'auto',required:true" style="width: 150px;">      
                        <option value="" selected="selected">.</option>
                        <option value="军研所">军研所</option>
                        <option value="商研所">商研所</option>
                        <option value="特研所">特研所</option>
                        <option value="海外室">海外室</option>
                    </select>
                </div>
            </div>
            <div class="row_container">
                
                    <span class="add_label">计划描述：</span>
                     <input id="jhms_edit" name="jhms" class="easyui-textbox" data-options="multiline:true,editable:false,prompt:'灰色区域内容由上面流水号匹配得出……',required:true" style="width:90%;height:80px;">
            
            </div>
        </td>
    </tr>
    <tr>
        <th>分组号</th>
        <td>
             

             <input id="dc" name="dcs" class="easyui-textbox" data-options="multiline:false,editable:true,prompt:'请输入分组号……',required:true" style="width:60%;">
            <br />
            <div id="content_wordage"></div>
        </td>
    </tr>
    <tr>
        <th>问题描述</th>
        <td>
             <textarea name="content" class="easyui-textbox" id="content_edit" style="width: 100%; height: 46px;"  data-options="required:true"></textarea>
            <br />
            <div id="content_wordage"></div>
        </td>
    </tr>
    <tr>
        <th>现场处理</th>
        <td>
             <textarea name="chuli" class="easyui-textbox" id="chuli_edit" style="width: 100%; height: 46px;" onkeyup="" data-options="required:true"></textarea>
            <br />
            <div id="chuli_wordage"></div>
        </td>
    </tr>
   
    <tr>
        <th>备注</th>
        <td>
            
             <textarea name="bz" class="easyui-textbox" id="bz_edit" style="width: 100%; height: 46px;" onkeyup="" data-options=""></textarea>
            <br />
            <div id="bz_wordage"></div>
        </td>
    </tr>
</table>


    <input type="hidden" name="userid" id="userid_edit" value= <?php echo ($_SESSION['uid']); ?>>
    <input type="hidden" name="id" id="id_edit">
    </form>
</div>
<div id="dlg-edit">
    <div class="tool_tip">只有自己发布的装配问题记录才能进行编辑！！</div>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="edit()">确认</a>
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#edit').dialog('close')">取消</a>
</div>

<script type="text/javascript">
    // 匹配MES信息
    function pipei1(){

        // 匹配之前西安清空
        $('#lshqj_edit').textbox('clear');
        $('#jsh_edit').textbox('clear');
        $('#cx_edit').textbox('clear');
        $('#pt_edit').textbox('clear');
        $('#jhms_edit').textbox('clear');
        $('#cxch_edit').textbox('clear');
        $('#jxh_edit').textbox('clear');
        var lsh=$('#lshpp_edit').textbox('getText');
        if(lsh!=""){
             $.post("/degs/index.php/Home/Quality/pipei",{lsh:lsh},function(result){
                 // $("span").html(result);

                 if(result.status=='1'){
                    $('#lshqj_edit').textbox('setValue',result.data.lshqj);
                    $('#jsh_edit').textbox('setValue',result.data.sjjhh);
                    $('#cx_edit').textbox('setValue',result.data.cl);
                    $('#pt_edit').textbox('setValue',result.data.jss);
                    $('#jhms_edit').textbox('setValue',result.data.cjpz);
                    $('#cxch_edit').textbox('setValue',result.data.cxch);
                    $('#jxh_edit').textbox('setValue',result.data.jxh);
                     var leibie=$('#leibie_edit').combobox('getValue');
                    if(leibie=='sj'){
                       $('#fkbm_edit').combobox('setValue', result.data.fkbm); 
                   }else{
                    $('#fkbm_edit').combobox('setValue', '');
                   }
                 }else{
                    $.messager.alert('匹配车型信息', result.data, 'info');
                 }

            },"json");
        }else{
            $.messager.alert('匹配车型信息', '请输入流水号', 'info');
        }
    }
</script>

<div id="pl" class="easyui-dialog"
	style="width: 580px; height: 240px; padding: 5px; overflow: hidden;"
	title="&nbsp;&nbsp;回复"
	data-options="iconCls:'icon-standard-building-add',buttons:'#pl-add',closed:true,resizable:false,modal:false,closable:true">


	<form id="add_pl" method="post">
	
       <input type="hidden" name="id" id="hideid"/>
		
       <input name="pl_text" id="pl_text" class="easyui-textbox" style="width: 100%; height: 150px;"  data-options="multiline:true,prompt:'请输入对此问题的回复...'"/>
					<br />
					<input type="text" name="test" style="display:none"/>
					
	</form>
	

</div>

<div id="pl-add">
	<div class="tool_tip" id="pl_contentwordage">
		</div>
	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
		onclick="pinglun()">确认</a>
	<a href="#" class="easyui-linkbutton"
		data-options="iconCls:'icon-cancel'"
		onclick="javascript:$('#pl').dialog('close')">取消</a>
</div>
<script>
$(document).ready(function(){
    var limitNum = 255;
    var pattern = '还可以输入' + limitNum + '字符';
    $('#pl_contentwordage').html(pattern);
    $('#pl_text').keyup(
    function(){
        var remain = $(this).val().length;
        if(remain > limitNum){
                pattern = "字数超过限制！";
            }else{
                var result = limitNum - remain;
                pattern = '还可以输入' + result + '字符';
            }
            $('#pl_contentwordage').html(pattern);
        }
    );
    
   
 
});
</script>
<style>
	.photo_view {
		width: 660px;
		height: 100px;
		text-align: center;
	}
	.zoomableContainer {
		height: 95%;
		text-align: center;
		content-align: center;
	}

</style>
<div id="view" class="easyui-dialog" style="width:833px;height:673px;padding:2px;overflow:hidden;" title="&nbsp;&nbsp;查看记录" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-view',closed:true,resizable:true,modal:true,closable:true">
	<div id="printview">

		<input id='rowIndex' type="hidden" class="easyui-textbox" style="height:0px"></input>
		<table cellspacing="0" class="table_view" 　summary="这是显示质量问题报表的表格">
		
			<caption class="view_title"> 陕汽乌海专用汽车有限公司装配问题记录</caption>

		
			<tr>
				<td class="thh">创建日期</td>
				<td id="creatdate_view"></td>
				<td class="thh">车间</td>
				<td id="cj_view"></td>
				<td class="thh">班次</td>
				<td id="bc_view">
				</td>
			</tr>
			<tr>
				<td class="thh">车&nbsp;&nbsp;型</td>
				<td id="cxch_view"></td>
				<td class="thh">车型平台</td>
				<td id="pt_view"></td>
				<td class="thh">车辆类型</td>
				<td id="cx_view">
				</td>
			</tr>
			<tr>
				<td class="thh">计生号</td>
				<td id="jsh_view"></td>
				<td class="thh">流水号</td>
				<td id="lsh_view"></td>
				<td class="thh">协议号</td>
				<td id="xy_view">
				</td>
			</tr>
			<tr>
				<td class="thh">问题类别</td>
				<td valign="middle" id="leibie_view"></td>
				<td class="thh">发布人</td>
				<td valign="middle" id="nickname_view"></td>
				<td class="thh">基线号</td>
				<td valign="middle" id="jxh_view"></td>
			</tr>
			<tr>
				<td class="thh">分组号</td>
				<td colspan="5" height="" id="dc_view"> </td>
			</tr>
			<tr>
				<td class="thh">问题描述</td>
				<td colspan="5" height="70px" id="content_view"> </td>
			</tr>
			<tr>
				<td class="thh">现场处理</td>
				<td colspan="5" height="70px" id="chuli_view"> </td>
			</tr>

			<tr>
				<td class="thh">图片文件</td>

				<td colspan="5" style="padding:0px;">

					
					
							<div class="photo_view" id="photo_viewOK">图片没有正确显示？</div
					

					</div>

				</td>

			</tr>
			
			<tr>
				<td class="thh">回复</td>
				<td colspan="5" height="140px"  style="vertical-align:top;">
				
					<div class="easyui-layout" data-options="fit:true">   
      
    <div id="huifu_view" data-options="region:'center',title:''" style="padding:5px;background:#eee;"></div>   
     <div data-options="region:'east',iconCls:'icon-reload',title:'',split:false,border:false" style="width:50%;">
     	

	<form id="add_pl1" method="post">
	
       <input name="pl_text" id="pl_text1" class="easyui-textbox" style="width: 100%; height: 100px;"  data-options="multiline:true,prompt:'您可以在此处添加回复内容...'"/>
					<br />
		
					
	</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
		onclick="pinglun1()">回复一下</a>
     </div>   

   
</div> 
				</td>
			</tr>
			


		</table>
	</div>
</div>

<div id="dlg-view">
	<div class="tool_tip">
		利用360浏览器自带的全屏功能可全屏观看图片！！！
	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-standard-arrow-left'" onclick="pre()">上一条</a>
	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-standard-arrow-right',iconAlign:'right'" onclick="next()">下一条</a>
	</div>
	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="down()">下载</a>
	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="plcolse()">取消</a>
</div>
<script>
function pinglun1(){
		 var row = $('#dg').datagrid("getSelected");
		
		 // $("#hideid1").value(row.id);
		 // console.log(row.id);

		 $('#add_pl1').form('submit', {
		 url : '/degs/index.php/Home/Quality/pinglunShow', 
		 onSubmit: function(param){    
        param.id = row.id;   
    },
    success: function(data){    
       var data = eval('(' + data + ')');
       if(data.status==1){
       	var huifu="";
       		for (var k = 0, length = data.data.length; k < length; k++) {
       		 	huifu='<span class="hfr">'+data.data[k].uname+'：['+data.data[k].time+']</span><div class="hfnr">'+data.data[k].huifu+'</div>'+huifu;
       		}
       		$("#huifu_view").html(huifu);
       		$('#pl_text1').textbox('setText',"");
// console.log(data.data); 
       }else{
       	$.messager.alert("回复", data.data, "info");
       }
				

    }    
});



	 }

	 function plcolse(){
	 	// $("#dg").datagrid("reload");
	 	$('#view').dialog('close');
	 }

	 	function pre() {

		var row = $('#dg').datagrid("getSelected");
		var rows = $('#dg').datagrid("getRows");
		if (row) {
			var indexid=$("#rowIndex").textbox('getValue');
			if(indexid==0){
				$.messager.alert("上一条", "这已经是第一条数据", "info");
			}else{
				indexid=parseInt(indexid)-1;
				$("#dg").datagrid("selectRow",indexid);
				$("#rowIndex").textbox('setValue',indexid);
				var rownow=rows[indexid];
			$("#creatdate_view").html(rownow.creatdate);
			$("#cj_view").html(cj(rownow.cj));
			$("#bc_view").html(banci(rownow.banci));
			
			$("#cxch_view").html(rownow.cxch);
			$("#pt_view").html(rownow.pt);
			$("#cx_view").html(rownow.cx);
			
			$("#jsh_view").html(rownow.jsh);
			$("#lsh_view").html(rownow.lsh);
			$("#xy_view").html(rownow.xy);
			$("#nickname_view").html(rownow.nickname);

			$("#leibie_view").html(leibie(rownow.leibie));
			$("#content_view").html(rownow.content);
			$("#chuli_view").html(rownow.chuli);
			$("#jxh_view").html(rownow.jxh);
$("#dc_view").html(rownow.dcs);

			$("#huifu_view").html(hfFormat2(rownow.huifu));
			var cla="pics2";

			

				if(row.pics.length>0){
					
					$("#photo_viewOK").html(pic(rownow.pics,cla));
				}else{
					$("#photo_viewOK").html("");
				}
				
			}

			
		} else {
			$.messager.alert("请选择要查看的记录", "请选择要查看的记录！", "info");
		}

	}
	 	function next() {

		var row = $('#dg').datagrid("getSelected");
		var rows = $('#dg').datagrid("getRows");
		var count=rows.length-1;
		if (row) {
			var indexid=$("#rowIndex").textbox('getValue',rowIndex);
			if(indexid==count){
				$.messager.alert("下一条", "这已经是本页最后一条数据", "info");
			}else{
				indexid=parseInt(indexid)+1;
				$("#dg").datagrid("selectRow",indexid);

					// console.log(indexid);
				$("#rowIndex").textbox('setValue',indexid);
				var rownow=rows[indexid];


			$("#creatdate_view").html(rownow.creatdate);
			$("#cj_view").html(cj(rownow.cj));
			$("#bc_view").html(banci(rownow.banci));
			
			$("#cxch_view").html(rownow.cxch);
			$("#pt_view").html(rownow.pt);
			$("#cx_view").html(rownow.cx);
			
			$("#jsh_view").html(rownow.jsh);
			$("#lsh_view").html(rownow.lsh);
			$("#xy_view").html(rownow.xy);
			$("#nickname_view").html(rownow.nickname);

			$("#leibie_view").html(leibie(rownow.leibie));
			$("#content_view").html(rownow.content);
			$("#chuli_view").html(rownow.chuli);
			$("#jxh_view").html(rownow.jxh);
			$("#dc_view").html(rownow.dcs);
			$("#huifu_view").html(hfFormat2(rownow.huifu));
			
			var cla="pics2";

			

			
				if(row.pics.length>0){
					$("#photo_viewOK").html("");
					$("#photo_viewOK").html(pic(rownow.pics,cla));
				}else{
					$("#photo_viewOK").html("");
				}
			}

			
		} else {
			$.messager.alert("请选择要查看的记录", "请选择要查看的记录！", "info");
		}

	}

</script>
<div id="showpic" class="easyui-dialog" style="width:650px;height:550px;padding:2px;overflow:hidden;" title="&nbsp;&nbsp;显示图片" data-options="iconCls:'icon-standard-folder-page',buttons:'#dlg-view',closed:true,resizable:true,modal:true,closable:true">
	<div id="pic_content" style="width:100%;height:100%;text-align:center;vertical-align: center"></div>
</div>



<div id="dlg-view">
	<div class="tool_tip">
		单击右键以保存图片！！

	</div>

	<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#showpic').dialog('close')">取消</a>
</div>

// <script>
// 	$('#pic_content').smartZoom({
// 					'containerClass' : 'zoomableContainer'
// 				}); 
// </script>




<style>
.detailtb td{
		/*background-color: rgba(133, 134, 136, 0.14);*/
		border: 1px solid #ccc;

	}
	.ditTitle{
		width:60px;font-weight:bold;color:#0E2D51;
		background-color: #F3F3F3;
	
	}
	.hfs{
		text-align: center;
		font-weight: bold;
		padding: 5px 0;
		color:#0E2D51;
		background-color: #F4F4F4
	}
	.hfr{
		font-weight: bold;
		padding-left:5px; 
	}
	.hfnr{
		padding:5px 2px 5px 15px; 
	}
	/*细节栏中的图片缩略图*/
	.picsl{
		width: 40px;
		padding:0 5px;
	}
	.picsl:hover{
		border:solid 1px #95B8E7;
		width: 35px;
		cursor: hand;
	}
	.pics2{
		max-width: 150px;
		max-height: 90px;
		padding:0 5px;

	}
</style>
<!-- 图片缩放穿件 -->

<script type="text/javascript">





	$('#dg').datagrid({
	url : '/degs/index.php/Home/Quality/read',
	toolbar : '#tool',
	pagination : true,
	fit : true,
	width : function() {
		return document.body.clientWidth * 0.9
	},
	nowrap : true,//
	collapsible : true,
	fitColumns : true,
	autoRowHeight : false,
	striped : true,//交替行
	singleSelect : true,//只允许选择一行
	rownumbers : true,
	border : false,
	sortName : 'creatdate',
	sortOrder : 'desc',//倒序排列
	remoteSort : false,
	pageSize : 30,
	method : "post",
	pageList : [ 10, 15, 30, 40, 50, 100, 200 ,500,1000],
	columns : [ [
			{
				field : 'id',
				checkbox : true
			},
			{
				field : 'content',
				title : '问题描述',
				width : 240
			},

			{
				field : 'chuli',
				title : '现场处理',
				width : 240
			},
			{
				field:'nickname',
				title:'发布人',
				hidden : 'true'
			},
        {
            field : 'jsh',
            title : '计生号',
            width : 160
        },{
            field : 'jxh',
            title : '计线号',
            width : 160,
        hidden : 'false'
        }, {
				field : 'cxch',
				title : '车型',
				width : 120,
				align : 'left'
			}, {
				field : 'userid',
				title : 'uesrid',
				width : 200,
				align : 'center',
				hidden : 'false'
			}, {
				field : 'banci',
				title : '班次',
				width : 40,
				align : 'left',
				formatter: function(value,row,index){
				
					return banci(value);
				
			}

				
			}
			, {
				field : 'creatdate',
				title : '时间',
				width : 160,
				align : 'left'
				
			}
			, {
				field : 'huifu',
				title : '回复',
				width : 40,
				formatter: function(value,row,index){
				if(value.length!=0){
					var data=$.parseJSON(value);
					var huifu=data.length+'条';
					var huifu='<span onclick="expandRow('+index+')">'+data.length+'条</span>';
				}else{
					huifu="";
				}
					return huifu;
				
			}				
			}
			, {
				field : 'dcs',
				title : '分组号',
				width : 140				
			}
			, {
				field : 'cj',
				title : '车间',
				width : 80,
				formatter: function(value,row,index){
				
				return cj(value);
			}				
			}


	] ],
	  onDblClickRow: function (rowIndex, rowData) { 
	  	// console.log(rowData);


	  	if(rowData){
	$("#view").dialog("open").dialog('setTitle', '&nbsp;&nbsp;查看记录');
		view() ;

			// $("#creatdate_view").html(rowData.creatdate);
			// $("#cj_view").html(cj(rowData.cj));
			// $("#bc_view").html(banci(rowData.banci));
			
			// $("#cxch_view").html(rowData.cxch);
			// $("#pt_view").html(pt(rowData.pt));
			// $("#cx_view").html(cx(rowData.cx));
			
			// $("#jsh_view").html(rowData.jsh);
			// $("#lsh_view").html(rowData.lsh);
			// $("#xy_view").html(rowData.xy);
			
			// $("#leibie_view").html(leibie(rowData.leibie));
			// $("#content_view").html(rowData.content);
			// $("#chuli_view").html(rowData.chuli);
			// $("#huifu_view").html(hfFormat(rowData.huifu));
			// var cla="pics2";
		
			
			// 	$("#photo_viewOK").html(pic(rowData.pics,cla));
	  	}else{
	  		console.log("没有数据！");
	  	}
	  },

	onLoadSuccess : function() {
		// $(".grid_pic").linkbutton({
		// 	text : '&nbsp;&nbsp;显示',
		// 	plain : true,
		// 	iconCls : 'icon-standard-picture'
		// });
$('#dg').datagrid('doCellTip',{cls:{'background-color':'#EAF1FF'},delay:600});
	},
	
	view: detailview, 
detailFormatter: function(rowIndex, rowData){ 
	var cla="picsl";//定义图片样式
return '<table width="100%" class="detailtb">' + 
 ' <tr>' + 
 '   <td class="ditTitle">问题描述</td>' + 
 '   <td style="width:300px;"> ' + rowData.content + '</td>' + 
 '   <td rowspan="3" style="width:200px;"><table style="width:100%" border="0">' + 
 '     <tr>' + 
 '       <td class="ditTitle">计生号</td>' + 
 '       <td>' + rowData.jsh + '</td>' + 
 '     </tr>' + 
 '     <tr>' + 
 '      <td class="ditTitle">流水号</td>' + 
 '      <td>' + rowData.lsh + '</td>' + 
 '   </tr>' + 
 '     <tr>' + 
 '       <td class="ditTitle">协议号</td>' + 
 '       <td>' + rowData.xy + '</td>' + 
 '     </tr>' + 
  '     <tr>' + 
 '       <td class="ditTitle">车型</td>' + 
 '       <td>' + rowData.cxch + '</td>' + 
 '     </tr>' + 
  '     <tr>' + 
 '       <td class="ditTitle">车型平台</td>' + 
 '       <td>' + rowData.pt+ '</td>' + 
 '     </tr>' + 
  '     <tr>' + 
 '       <td class="ditTitle">问题分类</td>' + 
 '       <td>' + leibie(rowData.leibie) + '</td>' + 
 '     </tr>' +
   '     <tr>' + 
 '       <td class="ditTitle">车辆类型</td>' + 
 '       <td>' + rowData.cx + '</td>' + 
 '     </tr>' +
   '     <tr>' + 
 '       <td class="ditTitle">发生车间</td>' + 
 '       <td>' + cj(rowData.cj) + '</td>' + 
 '     </tr>' + 
    '     <tr>' + 
 '       <td class="ditTitle">发布人</td>' + 
 '       <td>' + rowData.nickname + '</td>' + 
 '     </tr>' + 
  ' <tr>' + 
 '   <td class="ditTitle">研究院</td>' + 
 '   <td colspan="2">' + rowData.fkbm + '</td>' + 
'  </tr>' + 
 '   </table></td>' + 
 '   <td rowspan="4" style="width:400px;vertical-align:top;"> '+ hfFormat(rowData.huifu) +'</td>' + 
 ' </tr>' + 
 ' <tr>' + 
 '   <td class="ditTitle">现场处理</td>' + 
 '   <td>' + rowData.chuli + '</td>' + 
 ' </tr>' + 
 ' <tr>' + 
 '   <td class="ditTitle" style="height:130px">图片</td>' + 
 '   <td >' + pic(rowData.pics,cla) + '</td>' + 
'  </tr>' + 
 ' <tr>' + 
 '   <td class="ditTitle">备注</td>' + 
 '   <td colspan="2">' + rowData.bz + '</td>' + 
'  </tr>' + 
'</table>';


}

});


function expandRow(index){
	 $('#dg').datagrid('expandRow',index);
}

	$('#searchbox').searchbox({
		searcher : function(value, name) {

				
			 switch (name)
			 {
			 case 'content':
			 $('#dg').datagrid('load',{
			 content:value
			 });
			 break;
			 case 'chuli': 
			 $('#dg').datagrid('load',{
			 chuli:value
			 });
			 break;
			 case 'author': 
			 $('#dg').datagrid('load',{
			 author:value
			 });
			 break;

			 } 
		},
		menu : '#mm',
		prompt : '请输入搜索内容'
	});

//格式化图片下载
function pic(tp,cla){
var tp=escape2Html(tp.replace(/\\\//g,'/'));
var tp=$.parseJSON(tp);
var pics="";
for(var pici in tp){
		pics='<img src="/degs/Public/'+tp[pici].savename+'" alt="'+tp[pici].name+'" onclick="showpic(\'/degs/Public/'+tp[pici].savename+'\')" class="'+cla+'">'+pics;	
	}
	return pics;
}

function escape2Html(str) {
 var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
 return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}
// 格式化回复
function hfFormat(str){
	if(str.length!=0){
	var data=$.parseJSON(str);

	var huifu="";
	for(var item in data){
		huifu='<span class="hfr">'+data[item].uname+'：['+data[item].time+']</span><div class="hfnr">'+data[item].huifu+'</div>'+huifu;	
	}
	huifu='<div class="hfs">回复</div>'+huifu;
}else{
	huifu="";
}
	return huifu;		
}
// 格式化回复
function hfFormat2(str){
	if(str.length!=0){
	var data=$.parseJSON(str);

	var huifu="";
	for(var item in data){
		huifu='<span class="hfr">'+data[item].uname+'：['+data[item].time+']</span><div class="hfnr">'+data[item].huifu+'</div>'+huifu;	
	}
	// huifu='<div class="hfs">回复</div>'+huifu;
}else{
	huifu="";
}
	return huifu;		
}
function banci(bc){
	var banci1="";

	if(bc=='day'){
		 banci1="白班";
		}else{
			 banci1="夜班";
		}
	
		return banci1;
}
// 格式化类别
function leibie(val){
	var leibie="";
	switch(val)
	{
	case "lbj":
	  leibie="零部件";
	  break;
	 case "sj":
	  leibie="设计";
	  break;
	case "gy":
	  leibie="工艺";
	  break;
	case "zp":
	  leibie="装配";
	  break;
	  case "bzj":
	  leibie="标准件";
	  break;


	default:
	   leibie="其他";
	}
		return leibie;
}
// 格式化车型平台
// //   <option value="F3000">F3000</option>
//                     <option value="M3000">M3000</option>
//                     <option value="X3000">X3000</option>
//                     <option value="STR">奥龙</option>
//                     <option value="PZ">偏置</option>
//                     <option value="KY">矿用</option>
//                     <option value="QT">其他</option>
function pt(val){
	var leibie="";
	switch(val)
	{
	case "F3000":
	  leibie="F3000	";
	  break;
	  	case "M3000":
	  leibie="M3000";
	  break;
	 case "X3000":
	  leibie="X3000";
	  break;
	case "STR":
	  leibie="奥龙";
	  break;
	case "PZ":
	  leibie="偏置";
	  break;
	  case "KY":
	  leibie="矿用";
	  break;
	  case "QT":
	  leibie="其他";
	  break;
  case "JUN":
	  leibie="军车";
	  break;

	default:
	   leibie="其他";
	}
		return leibie;
}
// 格式化车辆类型
 // <option value="1">载货车</option>
 //                    <option value="2">越野车</option>
 //                    <option value="3">自卸车</option>
 //                    <option value="4">牵引车</option>
 //                    <option value="5">专用车</option>
 //                    <option value="6">其他</option>
function cx(val){
	var leibie="";
	switch(val)
	{
	case "1":
	  leibie="载货车";
	  break;
	case "2":
	  leibie="越野车";
	  break;
	case "3":
	  leibie="自卸车";
	  break;
	case "4":
	  leibie="牵引车";
	  break;
	case "5":
	  leibie="专用车";
	  break;
	  case "6":
	  leibie="其他";
	  break;

	default:
	   leibie="其他";
	}
		return leibie;
}
// 格式化车间
// <option value=""></option>
//                     <option value="zp1">装配一车间</option>
//                     <option value="zp2">装配二车间</option>
//                     <option value="sz1">试制一车间</option>
//                     <option value="sz2">试制二车间</option>
//                     <option value="ts">调试车间</option>
//                     <option value="yl">预留区</option>
function cj(val){
	var leibie="";
	switch(val)
	{
	case "zp1":
	  leibie="装配一车间";
	  break;
	case "zp2":
	  leibie="装配二车间";
	  break;
	case "sz1":
	  leibie="试制一车间";
	  break;
	case "sz2":
	  leibie="试制二车间";
	  break;
	case "ts":
	  leibie="调试车间";
	  break;
	  	case "ns":
	  leibie="内饰车间";
	  break;
	  case "yl":
	  leibie="预留区";
	  break;

	default:
	   leibie="其他";
	}
		return leibie;
}
	//对Date的扩展，将 Date 转化为指定格式的String 
	//月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
	//年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
	//例子： 
	//(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
	//(new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
	Date.prototype.Format = function(fmt) { //author: meizz 
		var o = {
			"M+" : this.getMonth() + 1, //月份 
			"d+" : this.getDate(), //日 
			"h+" : this.getHours(), //小时 
			"m+" : this.getMinutes(), //分 
			"s+" : this.getSeconds(), //秒 
			"q+" : Math.floor((this.getMonth() + 3) / 3), //季度 
			"S" : this.getMilliseconds()
		//毫秒 
		};
		if (/(y+)/.test(fmt))
			fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
					.substr(4 - RegExp.$1.length));
		for ( var k in o)
			if (new RegExp("(" + k + ")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
						: (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	}
	//今天、昨天 白班 夜班
	//打开添加窗口

	function showupload() {
		$('#showupload').window('open'); // open a window 	
	}

	function show_add() {
		$("#addok").linkbutton("enable");
		var myDate = new Date();
		var hours=myDate.getHours();
		var banci;
		if(hours>9 & hours<21)
		{
		banci='day';}
		else{
		banci='night';
		}
		$('#add_form').form('load', {
					banci : banci,
					cj : '',
					pt:'',
					cx:'',
					cxch : '',
					jsh:'',
					lsh:'',
					xy: '',
					content : '',
					chuli : '',
					bz : '',
					jhms:'',
					jxh:'',
					fkbm:'',
					dcs:''
				});
		$('#add').window('open'); // open a window 
		$('#creatdate').datetimebox('setValue', formatterDate(new Date()));	

}

//显示当前日期
formatterDate = function (date) {
var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
+ (date.getMonth() + 1);
var hor = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
return date.getFullYear() + '-' + month + '-' + day+" "+hor+":"+min+":"+sec;
};


function showpic(url) {
	im = document.createElement('img');
	im.src=url;

var pic='<img src="'+url+'" alt="图片" style="max-height:500px;max-width:600px"/>';

 $('#showpic').window('open');
	
$("#pic_content").html(pic);	
}



	function reload() {
		$('#dg').datagrid('reload', {   
		    cx: '' 
		});
	}
	function add() {
 // $("#addok").linkbutton("disable");
		$('#add_form').form('submit', {

			url : '/degs/index.php/Home/Quality/add_quality',

			success : function(data) {
				$("#dg").datagrid("reload");

				$.messager.alert('添加项目', data, 'info');
				$('#add').dialog('close')

			}
		});
	}

	//删除		
	function dele() {
		var row = $('#dg').datagrid("getSelected");
		var group_id="<?php echo ($_SESSION['group_id']); ?>".split(",");
		
			if (row.userid == "<?php echo ($_SESSION[ 'uid']); ?>" || $.inArray("1", group_id)!=-1 || $.inArray("2", group_id)!=-1)  {

			if (row) {
				$.messager.confirm('确认', '您确定要删除此项目吗?', function(r) {
					if (r) {
						$.post('/degs/index.php/Home/Quality/del', {
							id : row.id
						}, function(data) {
							if (data) {
								$.messager.alert('删除项目', data, 'info');
								$("#dg").datagrid("reload");
							} else {
								$.messager.show({ // show error message  
									title : '错误',
									msg : result.errorMsg
								});

							}
						}, 'text');
					}
				});
			} else {
				$.messager.alert("请选择", "请选择要删除的项目！", "info");
			}

		} else {

			$.messager.alert("无法删除", "此服务记录非您创建，无法删除！", "info");
		}

	}

	function show_edit() {

		var row = $('#dg').datagrid("getSelected");

		if (row) {
			//将session['group_id']转为数组
			var group_id="<?php echo ($_SESSION['group_id']); ?>".split(",");
		
			if (row.userid == "<?php echo ($_SESSION[ 'uid']); ?>" || $.inArray("1", group_id)!=-1 || $.inArray("2", group_id)!=-1)  {

				$("#edit").dialog("open").dialog('setTitle', '&nbsp;&nbsp;编辑服务记录');

			$("#edit_form").form("load", row);

			}else{
				$.messager.alert("无法编辑	", "此服务记录非您创建，无法编辑！", "info");
			}

			

		} else {
			$.messager.alert("请选择要编辑的行", "请选择要编辑的行！", "info");
		}

	}





	//查看项目，范建鹏2015年1月19日
	function view() {

		var row = $('#dg').datagrid("getSelected");
		console.log(row);
		var rowIndex=$('#dg').datagrid('getRowIndex',row);
		// console.log(row);
		if (row) {
			$("#rowIndex").textbox('setValue',rowIndex);//存储index
			$("#view").dialog("open").dialog('setTitle', '&nbsp;&nbsp;查看记录');
			
			$("#creatdate_view").html(row.creatdate);
			$("#cj_view").html(cj(row.cj));
			$("#bc_view").html(banci(row.banci));
			
			$("#cxch_view").html(row.cxch);
			$("#pt_view").html(row.pt);
			$("#cx_view").html(row.cx);
			
			$("#jsh_view").html(row.jsh);
			$("#lsh_view").html(row.lsh);
			$("#xy_view").html(row.xy);
			$("#nickname_view").html(row.nickname);

			$("#leibie_view").html(leibie(row.leibie));
			$("#content_view").html(row.content);
			$("#chuli_view").html(row.chuli);
			$("#jxh_view").html(row.jxh);
			console.log(row.jxh);
			$("#dc_view").html(row.dcs);
			$("#huifu_view").html(hfFormat2(row.huifu));
			var cla="pics2";

			

			
				$("#photo_viewOK").html(pic(row.pics,cla));
				
	
			$('#pl_text1').textbox('setText',"");

			

		} else {
			$.messager.alert("请选择要查看的记录", "请选择要查看的记录！", "info");
		}

	}
 	function edit() {
		$('#edit_form').form('submit', {
			type:'POST',
			 url : '/degs/index.php/Home/Quality/edit',
			success : function(data) {

				$('#edit').dialog('close')
				$("#dg").datagrid("reload");
				$.messager.alert('编辑质量信息', data, 'info');
				// 

			}
		});
	} 

	function page() {
		return $('#dg').datagrid('options').pageNumber;
	}
	function pagesize() {
		return $('#dg').datagrid('options').pagesize;
	}
	function excel() {
		
		var grid = $('#dg');  
		var options = grid.datagrid('getPager').data("pagination").options; 
		var pageNumber = options.pageNumber;  
		var pageSize=options.pageSize; 
		window.location.href='/degs/index.php/Home/Quality/out/page/'+pageNumber+'/pagesize/'+pageSize;	
	}
	
	function down(){
		var row = $("#dg").datagrid("getSelected");
		var id=row.id;	
		window.location.href='/degs/index.php/Home/Quality/down/id/'+id;
	}
	function show_pinlun() {

		var row = $('#dg').datagrid("getSelected");
		
		if (row) {

			
			$('#pl').window('open');
			$("#hideid").val(row.id);

			$('#pl_text').textbox('clear');
			// $("#hidepl").val(row.huifu);
			


		} else {
			$.messager.alert("请选择要进行评论的记录", "请选择要评论的记录！", "info");
		}

	}

	function print_view() {
		$("#printview").jqprint({
			debug : true,
			printContainer : true
		});
	}


function pinglun(){
		 // var row = $("#dg").datagrid("getSelected");

			$('#add_pl').form('submit', {
				type:'POST',
				 url : '/degs/index.php/Home/Quality/pinglun',
				success : function(data) {
					$('#pl').dialog('close')
					$("#dg").datagrid("reload");
					$.messager.alert('回复装配问题', data, 'info');
					// console.log(data);
					

				}
			});
	 }


</script>